import { request } from '../utils/request'

// 获取频道列表
export function getChannelAPI () {
  return request({
    url: '/channels',
    method: 'GET'
  })
}

// 发布文章
export function articlePublishAPI (data) {
  return request({
    url: '/mp/articles',
    method: 'POST',
    params: {
      draft: false
    },
    data: data
  })
}

// 获取文章列表
export function getArticleAPI (params) {
  return request({
    url: '/mp/articles',
    method: 'GET',
    params
  })
}

// 删除文章
export function deleteArticleAPI (target) {
  return request({
    url: `/mp/articles/${target}`,
    method: 'DELETE'
  })
}

// 获取文章详情
export function getArticleDetailAPI (target) {
  return request({
    url: `mp/articles/${target}`,
    method: 'GET'
  })
}

// 编辑文章
export function editArticleAPI (data) {
  return request({
    url: `mp/articles/${data.id}`,
    method: 'PUT',
    params: {
      draft: false
    },
    data
  })
}
